//ajax读取部门和员工js函数
/**************************************ajax查询 部门、员工组合使用 显示为下来列表组件  开始***************************************/
/**
 * 功能说明: 初始化页面组件 参数说明: objStr: 查询组件放到的容器ID字符串 config{ deptStr:"deptStr"
 * //部门输入框ID名称 默认 deptStr deptStrW:'70px' //部门输入框的宽度 默认70px
 * deptHiddenId:"deptHiddenId" //部门ID隐藏域ID名称 默认deptHiddenId
 * workerStr:"workerStr" //员工输入框ID名称 默认 workerStr workerStrW:'70px' //员工输入框宽度
 * 默认70px workerHiddenId:"workerHiddenId" //员工ID隐藏域ID名称 默认workerHiddenId
 * showId:"showId" //点击显示员工组件ID名称 默认 showId showLeft:'100px' //员工下拉箭头距离left的距离
 * 默认100px showTop:'100px' //员工下拉箭头距离top的距离 默认100px
 * handWorkerFun:'setWorkerInfo' //员工输入框赋值回调函数 默认 setWorkerInfo handDeptFun :
 * 'setDeptInfo' //部门输入框赋值回调函数 默认 setDeptInfo }
 */
function deptWorkerInit(objStr, configPar) {
	/** *******参数******* */
	this.obj = objStr;
	configPar = configPar || {};
	var defaults = {
		deptStr : "deptStr",
		deptStrW : '100px',
		deptHiddenId : "deptHiddenId",
		workerStr : "workerStr",
		workerStrW : '100px',
		workerHiddenId : "workerHiddenId",
		showId : "showId",
		showLeft : '100px',
		showTop : '100px',
		handWorkerFun : 'setWorkerInfo',
		handDeptFun : 'setDeptInfo'
	};
	this.config = $.extend(defaults, configPar);
	var optionsConfig = this.config;
	/** ********初始化页面组件********* */
	var moduleHTML = [];
	moduleHTML.push('<input type="text" name="' + this.config.deptStr
			+ '" id="' + this.config.deptStr + '" style="width:'
			+ this.config.deptStrW
			+ '" title="输入部门名称(汉字或拼音首字母)" autocomplete="off"/>');
	moduleHTML.push('<input type="hidden" name="' + this.config.deptHiddenId
			+ '" id="' + this.config.deptHiddenId + '"/>');
	moduleHTML
			.push('<input type="text" name="'
					+ this.config.workerStr
					+ '" id="'
					+ this.config.workerStr
					+ '" style="width:'
					+ this.config.workerStrW
					+ '" title="输入员工姓名(汉字或拼音首字母)" autocomplete="off" onfocus="showDWResult(\'results_'
					+ this.config.workerStr + '\')"/>');
	moduleHTML.push('<input type="hidden" name="' + this.config.workerHiddenId
			+ '" id="' + this.config.workerHiddenId + '"/>');
	// moduleHTML.push('<span
	// style="position:absolute;cursor:pointer;top:'+this.config.showTop+';left:'+this.config.showLeft+';"
	// id="'+this.config.showId+'"
	// onclick="showDWResult(\'results_'+this.config.workerStr+'\')"><img
	// src="/images/icon/xialajiantou.gif" title="点击显示员工"/></span>');
	$("#" + this.obj).html(moduleHTML.join(''));
	moduleHTML = null;
	// 绑定事件
	bindEvent(optionsConfig);
}

/**
 * 功能说明:Ajax部门查询
 */
function searchDept(config) {
	var setWorkerFunName = config.handWorkerFun == "undefined"
			|| config.handWorkerFun.length == 0 ? "setWorkerInfo"
			: config.handWorkerFun;
	var setDeptFunName = config.handDeptFun == "undefined"
			|| config.handDeptFun.length == 0 ? "setDeptInfo"
			: config.handDeptFun;
	var deptSearchStr = $("#" + config.deptStr).val();
	if (typeof (deptSearchStr) == 'undefined'
			|| $.trim(deptSearchStr).length <= 0) {
		$("#" + config.deptHiddenId).val('');
		hideDWResult('results_' + config.deptStr);
		return;
	}
	// ajax
	$
			.ajax({
				type : 'POST',
				dataType : 'json',
				url:_rootPath+'/v/deptworker/ajaxgetdept',
				data : {
					deptStr : $.trim(deptSearchStr)
				},
				success : function(msg) {
					var data = msg;
					var contentHTML = [];
					contentHTML
							.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;">');
					contentHTML
							.push('<li style="background-color:#FFD700;text-indent:3px;line-height:2;color:#3c3c64;width:100%;">');
					contentHTML
							.push('<span style="float:right;cursor:pointer;" onclick="hideDWResult(\'results_'
									+ config.deptStr
									+ '\');">[关闭]</span>部门列表</li>');
					var le = 0;
					if (data.infoNo == 1) {
						var jsonArr = eval(data.deptArr) || [];
						le = jsonArr.length;
						for ( var i = 0; i < le; i++) {
							if (i % 2 == 0) {
								contentHTML
										.push("<li style='width:100%;background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='setDeptInfo(\""
												+ config.workerStr
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setDeptFunName
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							} else {
								contentHTML
										.push("<li style='width:100%;background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='"
												+ setDeptFunName
												+ "(\""
												+ config.workerStr
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setDeptFunName
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							}
							contentHTML.push(jsonArr[i].deptName + "</li>");
						}
					} else {
						contentHTML
								.push('<li style="width:100%;background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;"><无匹配数据></li>');

					}
					contentHTML.push('</ul>');
					contentHTML
							.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:180px; height:2000px; z-index:-1; background:#DFFEBA;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"  ></iframe>');
					$("#results_" + config.deptStr)
							.append(contentHTML.join(''));
					contentHTML = "";
					if (le < 10) {
						$("#results_" + config.deptStr).css("height", "auto");
						$("#results_" + config.deptStr).css("overflow-y",
								"hidden");
					} else {
						$("#results_" + config.deptStr).css("height", "266px");
						$("#results_" + config.deptStr).css("overflow-y",
								"auto");
					}
					// 显示
					showDWResult("results_" + config.deptStr);
				}
			});
}

/**
 * 功能说明: ajax查询员工
 */
function searchWorker(config, flg) {
	var setWorkerFunName = config.handWorkerFun == "undefined"
			|| config.handWorkerFun.length == 0 ? "setWorkerInfo"
			: config.handWorkerFun;
	var workerSearchStr = $("#" + config.workerStr).val();// 输入的员工信息
	var deptId = $("#" + config.deptHiddenId).val();// 部门ID
	if ((typeof (workerSearchStr) == 'undefined' || $.trim(workerSearchStr).length <= 0)
			&& (typeof (deptId) == 'undefined' || "" == deptId || isNaN(deptId) || parseInt(deptId) <= 0)) {
		$("#" + config.workerHiddenId).val('');
		hideDWResult('results_' + config.workerStr);
		return;
	}
	// 如果没有显示域则创建 主要解决是选择部门后还没创建员工的显示域
	if ($("#results_" + config.workerStr).length <= 0) {
		var rLeft = $("#" + config.workerStr).offset().left;// 设置层的left为指定组件的left距离
		// var
		// rTop=$("#"+config.workerStr).offset().top+$("#"+config.workerStr).height()+5;//设置层的top距离

		$("#" + config.workerStr)
				.after(
						'<div id="results_'
								+ config.workerStr
								+ '" style="border:1px solid #000000; overflow-x:hidden;width:230px;height:auto;background:#FCFCFC;position:absolute;left:'
								+ rLeft
								+ 'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;"></div>');
	}
	// ajax
	$
			.ajax({
				type : 'POST',
				dataType : 'json',
				url:_rootPath+'/v/deptworker/ajaxgetworker',
				data : {
					workerStr : $.trim(workerSearchStr),
					workerDeptId : deptId
				},
				success : function(msg) {
					var data = msg;
					var contentHTML = [];
					contentHTML
							.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;">');
					contentHTML
							.push('<li style="width:100%;background-color:#FFD700;text-indent:3px;line-height:2;color:#3c3c64;">');
					contentHTML
							.push('<span style="float:right;cursor:pointer;" onclick="hideDWResult(\'results_'
									+ config.workerStr
									+ '\');">[关闭]</span>员工列表</li>');
					var le = 0;
					if (data.infoNo == 1) {
						var jsonArr = eval(data.workerArr) || [];
						le = jsonArr.length;
						for ( var i = 0; i < le; i++) {
							if (i % 2 == 0) {
								contentHTML
										.push("<li style='width:100%;background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='setWorkerInfo(\""
												+ jsonArr[i].workerName
												+ "\",\""
												+ config.workerStr
												+ "\",\""
												+ jsonArr[i].id
												+ "\",\""
												+ jsonArr[i].workerId
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							} else {
								contentHTML
										.push("<li style='width:100%;background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='setWorkerInfo(\""
												+ jsonArr[i].workerName
												+ "\",\""
												+ config.workerStr
												+ "\",\""
												+ jsonArr[i].id
												+ "\",\""
												+ jsonArr[i].workerId
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							}
							contentHTML.push(jsonArr[i].deptName
									+ "&nbsp;&nbsp;<strong>"
									+ jsonArr[i].workerName + "</strong></li>");
						}
					} else {
						contentHTML
								.push('<li style="width:100%;background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;"><无匹配数据></li>');

					}
					contentHTML.push('</ul>');
					contentHTML
							.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:200px; height:2000px; z-index:-1; background:#DFFEBA;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"></iframe>');
					$("#results_" + config.workerStr)
							.html(contentHTML.join(''));
					contentHTML = "";
					if (le < 10) {
						$("#results_" + config.workerStr).css("height", "auto");
						$("#results_" + config.workerStr).css("overflow-y",
								"hidden");
					} else {
						$("#results_" + config.workerStr)
								.css("height", "266px");
						$("#results_" + config.workerStr).css("overflow-y",
								"auto");
					}
					// 显示结果域
					if (flg)
						showDWResult("results_" + config.workerStr);
				}
			});
}

/**
 * 功能说明: 绑定输入框事件
 */
function bindEvent(config) {
	// 部门输入框事件
	$("#" + config.deptStr)
			.bind(
					"keyup",
					function(evt) {
						if ($("#results_" + config.deptStr).length <= 0) {
							var rLeft = $(this).offset().left;// 设置层的left为指定组件的left距离
							// var
							// rTop=$(this).offset().top+$(this).height()+5;//设置层的top距离
							$(this)
									.after(
											'<div id="results_'
													+ config.deptStr
													+ '" style="border:1px solid #000000; overflow-x:hidden;width:200px;height:auto;background:#FCFCFC;position:absolute;left:'
													+ rLeft
													+ 'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;padding-left:0;"></div>');
						}
						$("#results_" + config.deptStr).html("");
						searchDept(config);// ajax查询
					});
	// 员工输入框事件
	$("#" + config.workerStr)
			.bind(
					"keyup",
					function() {
						if ($("#results_" + config.workerStr).length <= 0) {
							var rLeft = $(this).offset().left;// 设置层的left为指定组件的left距离
							// var
							// rTop=$(this).offset().top+$(this).height()+5;//设置层的top距离
							$(this)
									.after(
											'<div id="results_'
													+ config.workerStr
													+ '" style="border:1px solid #000000; overflow-x:hidden;width:230px;height:auto;background:#FCFCFC;position:absolute;left:'
													+ rLeft
													+ 'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;padding-left:0;"></div>');
						}
						$("#results_" + config.workerStr).html("");
						searchWorker(config, true);// ajax查询
					});
}
/**
 * 功能说明:设置员工信息 参数说明: workerName //员工姓名值 configWorkerName //员工输入框组件ID字符串 workerId
 * //员工记录ID值 configWorkerId //员工ID隐藏域组件ID字符串 deptName //部门名称值 configDeptName
 * //部门输入框组件ID字符串 deptId //部门ID值 configDeptId //部门隐藏域自己ID字符串
 * 
 */
function setWorkerInfo(workerName, configWorkerName, id, workerId,
		configWorkerId, deptName, configDeptName, deptId, configDeptId,
		setWorkerFun) {
	// alert(":workerName="+workerName+":workerId="+workerId+":deptName="+deptName+":deptId="+deptId);
	$("#" + configWorkerName).val(workerName);
	// 如果页面定义了一个 workerId__Flag 变量 ，那么就取workerId,如果没定义则使用自增长ID
	if (typeof workerId__Flag == "undefined") {
		$("#" + configWorkerId).val(id);
	} else {
		$("#" + configWorkerId).val(workerId);
	}
	$("#" + configDeptName).val(deptName);
	$("#" + configDeptId).val(deptId);
	hideDWResult("results_" + configWorkerName);

	if (setWorkerFun != "setWorkerInfo") {
		eval(setWorkerFun + "(1)");
	}
}
/**
 * 功能说明: 设置部门信息 参数说明: configWorkerName //员工输入框组件ID字符串 configWorkerId
 * //员工隐藏域组件ID字符串 deptName //部门名称值 configDeptName //部门输入框组件ID字符串 deptId //部门ID值
 * configDeptId //部门隐藏域组件ID字符串
 */
function setDeptInfo(configWorkerName, configWorkerId, deptName,
		configDeptName, deptId, configDeptId, setWorkerFun, setDeptFun) {
	// alert(":deptName="+deptName+":deptId="+deptId);
	var config = {
		deptStr : configDeptName,
		deptHiddenId : configDeptId,
		workerStr : configWorkerName,
		workerHiddenId : configWorkerId,
		handWorkerFun : setWorkerFun
	};
	$("#" + configWorkerName).val("");
	$("#" + configWorkerId).val("");
	$("#" + configDeptName).val(deptName);
	$("#" + configDeptId).val(deptId);
	hideDWResult("results_" + configDeptName);

	if (setDeptFun != "setDeptInfo") {
		eval(setDeptFun + "(2)");
	}

	searchWorker(config, false);// ajax查询员工
}
/**
 * ************************************ajax查询 部门、员工组合使用 显示为下来列表组件
 * 结束**************************************
 */
/**
 * **************************************可独立ajax查询 部门、员工 显示为下来列表
 * 开始****************************************
 */

/**
 * 功能说明:Ajax部门查询 参数说明:config 为{deptStr:'',deptHiddenId:'',handleFun:''}的json格式
 * deptStr为输入框ID字符串 deptHiddenId为存放部门ID信息隐藏域ID字符串 handleFun:需要进一步处理的自定义函数
 * 参数为部门json格式信息{deptId:'',deptName:''},如需要关闭请调用
 * hideDWResult('results_输入框ID字符串');
 * 调用示例:onkeyup="ajaxGetDept({deptStr:'parentDeptName',deptHiddenId:'parentDeptNumber',handleFun:'setDeptInfo'})"
 */
function ajaxGetDept(config) {
	var deptSearchStr = $("#" + config.deptStr).val();
	if (typeof (deptSearchStr) == 'undefined'
			|| $.trim(deptSearchStr).length <= 0) {
		$("#" + config.deptHiddenId).val('');
		hideDWResult('results_' + config.deptStr);
		return;
	}
	// 创建下拉显示层
	if ($("#results_" + config.deptStr).length <= 0) {
		var rLeft = $("#" + config.deptStr).offset().left;// 设置层的left为指定组件的left距
		$("#" + config.deptStr)
				.after(
						'<div id="results_'
								+ config.deptStr
								+ '" style="border:1px solid #000000; overflow-x:hidden;width:200px;height:auto;background:#FCFCFC;position:absolute;left:'
								+ rLeft
								+ 'px;margin-top:22px;z-index:9999;font-size:12px;display:none;padding-left:0;"></div>');
	}
	$("#results_" + config.deptStr).html("");
	// ajax
	$
			.ajax({
				type : 'POST',
				dataType : 'json',
				url:_rootPath+'/v/deptworker/ajaxgetdept',
				data : {
					deptStr : $.trim(deptSearchStr)
				},
				success : function(msg) {
					var data = msg;
					var contentHTML = [];
					contentHTML
							.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;">');
					contentHTML
							.push('<li style="background-color:#FFD700;text-indent:3px;line-height:2;color:#3c3c64;width:100%;">');
					contentHTML
							.push('<span style="float:right;margin-right:20px;cursor:pointer;" onclick="hideDWResult(\'results_'
									+ config.deptStr
									+ '\');">[关闭]</span>部门列表</li>');
					var le = 0;
					if (data.infoNo == 1) {
						var jsonArr = eval(data.deptArr) || [];
						le = jsonArr.length;
						for ( var i = 0; i < le; i++) {
							if (i % 2 == 0) {
								contentHTML
										.push("<li style='background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:100%;' onclick='"
												+ config.handleFun
												+ "("
												+ doJSONObjToStr(jsonArr[i])
												+ ")'>");
							} else {
								contentHTML
										.push("<li style='background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:100%;' onclick='"
												+ config.handleFun
												+ "("
												+ doJSONObjToStr(jsonArr[i])
												+ ")'>");
							}
							contentHTML.push(jsonArr[i].deptName + "</li>");
						}
					} else {
						contentHTML
								.push('<li style="background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;width:100%;"><无匹配数据></li>');

					}
					contentHTML.push('</ul>');
					contentHTML
							.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:180px; height:1000px; z-index:-1; background:#DFFEBA;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"  ></iframe>');
					$("#results_" + config.deptStr).html(contentHTML.join(''));
					contentHTML = "";
					if (le < 10) {
						$("#results_" + config.deptStr).css("height", "auto");
						$("#results_" + config.deptStr).css("overflow-y",
								"hidden");
					} else {
						$("#results_" + config.deptStr).css("height", "266px");
						$("#results_" + config.deptStr).css("overflow-y",
								"auto");
					}
					// 显示
					showDWResult("results_" + config.deptStr);
				}
			});
}

/**
功能说明:Ajax查询员工
参数说明:config 为{workerStr:'',workerHiddenId:'',handleFun:''}的json格式            
	   workerStr为输入框ID字符串
	   workerHiddenId为存放员工ID信息隐藏域ID字符串
	   handleFun:需要进一步处理的自定义函数,自动传递参数 参数为员工json格式信息{workerName:"",workerId:"",deptId:"",deptName:''},如需要关闭请调用  hideDWResult('results_输入框ID字符串');
调用示例:onkeyup="ajaxGetWorker({workerStr:'workerName',workerHiddenId:'workerId',handleFun:"setWorkerInfo"})"
*/
function ajaxGetWorker(config){
 var workerSearchStr=$("#"+config.workerStr).val();//输入的员工信息
 $("#"+config.workerHiddenId).val('');
 if((typeof(workerSearchStr)=='undefined' || $.trim(workerSearchStr).length<=0)){
	hideDWResult('results_'+config.workerStr);
	return;
 }
 //如果没有显示域则创建 主要解决是选择部门后还没创建员工的显示域
 if($("#results_"+config.workerStr).length<=0){
	    var rLeft=0;
		if('undefined' == typeof(config.rleft) ){
			rLeft=$("#"+config.workerStr).offset().left;//设置层的left为指定组件的left距离 
		}else{
			rLeft =config.rleft;
			
		}
		$("#"+config.workerStr).after('<div id="results_'+config.workerStr+'" style="border:1px solid #000000; overflow-x:hidden;width:230px;height:auto;background:#FCFCFC;position:absolute;left:'+rLeft+'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;"></div>'); 
  }
 //ajax
  $.ajax({
	      type:'POST',
		  dataType:'json',
		  url:_rootPath+'/v/deptworker/ajaxgetworker',
		  data:{workerStr:$.trim(workerSearchStr)},
		  success:function(msg){
				var data=msg;	
				var contentHTML=[];
				var le=0;
				
				if(data.infoNo==1){			
					var jsonArr=eval(data.workerArr) || [];
					le=jsonArr.length;
					var h=(le+1)*24;
					contentHTML.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;height:'+h+'px">');
					contentHTML.push('<li style="background-color:#AFD9E6;text-indent:3px;line-height:2;color:#3c3c64;width:230px;text-align:left;float:left">');
					contentHTML.push('<span style="float:right;margin-right:20px;cursor:pointer;" onclick="hideDWResult(\'results_'+config.workerStr+'\');">[关闭]</span>员工列表</li>');
					for(var i=0;i<le;i++){	
					   if(i%2==0){
						contentHTML.push("<li style='background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:230px;' onclick='"+config.handleFun+"("+ doJSONObjToStr(jsonArr[i])+")'>");			
						}
						else{
							contentHTML.push("<li style='background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:230px;' onclick='"+config.handleFun+"("+ doJSONObjToStr(jsonArr[i])+")'>");			
						}
						contentHTML.push("<span style='text-align:left;float:left;width:140px;'>"+jsonArr[i].deptName+"</span><strong style='text-align:left;float:left'>"+jsonArr[i].workerName+"</strong></li>");
					 }
				}
				else{						
					contentHTML.push('<li style="background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;width:230px;"><无匹配数据></li>');
							
				}
				contentHTML.push('</ul>');
				contentHTML.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:200px; height:'+h+'px; z-index:-1; background:#FFFFFF;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"></iframe>');
				$("#results_"+config.workerStr).html(contentHTML.join(''));
				contentHTML="";
				if(le<10){
					$("#results_"+config.workerStr).css("height","auto");
					$("#results_"+config.workerStr).css("overflow-y","hidden");
				}else{
					$("#results_"+config.workerStr).css("height","266px");
					$("#results_"+config.workerStr).css("overflow-y","auto");			
				}
			  //显示结果域
			  showDWResult("results_"+config.workerStr);
		 }
  });	
}

/**
 * 只查询自己下属
 * @param config
 */
function ajaxGetWorkerById(config){
	 var workerSearchStr=$("#"+config.workerStr).val();//输入的员工信息
	 if((typeof(workerSearchStr)=='undefined' || $.trim(workerSearchStr).length<=0)){
		$("#"+config.workerHiddenId).val('');
		hideDWResult('results_'+config.workerStr);
		return;
	 }
	 //如果没有显示域则创建 主要解决是选择部门后还没创建员工的显示域
	 if($("#results_"+config.workerStr).length<=0){
		    var rLeft=0;
			if('undefined' == typeof(config.rleft) ){
				rLeft=$("#"+config.workerStr).offset().left;//设置层的left为指定组件的left距离 
			}else{
				rLeft =config.rleft;
			}
			$("#"+config.workerStr).after('<div id="results_'+config.workerStr+'" style="border:1px solid #000000; overflow-x:hidden;width:230px;height:auto;background:#FCFCFC;position:absolute;left:'+rLeft+'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;"></div>'); 
	  }
	 //ajax
	  $.ajax({
		      type:'POST',
			  dataType:'json',
			  url:_rootPath+'/v/deptworker/ajaxGetWorkerById',
			  data:{workerStr:$.trim(workerSearchStr),workerId:currWorkerId},
			  success:function(msg){
					var data=msg;	
					var contentHTML=[];
					var le=0;
					
					if(data.infoNo==1){			
						var jsonArr=eval(data.workerArr) || [];
						le=jsonArr.length;
						var h=(le+1)*24;
						contentHTML.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;height:'+h+'px">');
						contentHTML.push('<li style="background-color:#AFD9E6;text-indent:3px;line-height:2;color:#3c3c64;width:230px;text-align:left;float:left">');
						contentHTML.push('<span style="float:right;margin-right:20px;cursor:pointer;" onclick="hideDWResult(\'results_'+config.workerStr+'\');">[关闭]</span>您的下属</li>');
						for(var i=0;i<le;i++){	
						   if(i%2==0){
							contentHTML.push("<li style='background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:230px;' onclick='"+config.handleFun+"("+ doJSONObjToStr(jsonArr[i])+")'>");			
							}
							else{
								contentHTML.push("<li style='background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;width:230px;' onclick='"+config.handleFun+"("+ doJSONObjToStr(jsonArr[i])+")'>");			
							}
							contentHTML.push("<span style='text-align:left;float:left;width:140px;'>"+jsonArr[i].deptName+"</span><strong style='text-align:left;float:left'>"+jsonArr[i].workerName+"</strong></li>");
						 }
					}
					else{						
						contentHTML.push('<li style="background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;width:230px;"><无匹配数据></li>');
								
					}
					contentHTML.push('</ul>');
					contentHTML.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:200px; height:'+h+'px; z-index:-1; background:#FFFFFF;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"></iframe>');
					$("#results_"+config.workerStr).html(contentHTML.join(''));
					contentHTML="";
					if(le<10){
						$("#results_"+config.workerStr).css("height","auto");
						$("#results_"+config.workerStr).css("overflow-y","hidden");
					}else{
						$("#results_"+config.workerStr).css("height","266px");
						$("#results_"+config.workerStr).css("overflow-y","auto");			
					}
				  //显示结果域
				  showDWResult("results_"+config.workerStr);
			 }
	  });	
	}
/**
 * **************************************可独立ajax查询 部门、员工 显示为下来列表
 * 结束****************************************
 */
/**
 * **************************************公共函数
 * 开始**********************************************************************
 */
/**
 * 功能说明:显示结果域
 */
function showDWResult(resultDiv) {
	if ($("#" + resultDiv).length > 0)
		$("#" + resultDiv).show("slow");
}
/**
 * 功能说明:隐藏结果域
 */
function hideDWResult(resultDiv) {
	if ($("#" + resultDiv).length > 0)
		$("#" + resultDiv).hide("slow");
}

/**
 * 功能说明:JSON对象转换为json格式字符串
 */
function doJSONObjToStr(jsonObj) {
	var str = [];
	for ( var n in jsonObj) {
		str.push(n + ":\"" + jsonObj[n] + "\"");
	}
	return "{" + str.join(',') + "}";
}
/**
 * **************************************公共函数
 * 结束*********************************************************************
 */


function searchWorker(config, flg) {
	var setWorkerFunName = config.handWorkerFun == "undefined"
			|| config.handWorkerFun.length == 0 ? "setWorkerInfo"
			: config.handWorkerFun;
	var workerSearchStr = $("#" + config.workerStr).val();// 输入的员工信息
	var deptId = $("#" + config.deptHiddenId).val();// 部门ID
	if ((typeof (workerSearchStr) == 'undefined' || $.trim(workerSearchStr).length <= 0)
			&& (typeof (deptId) == 'undefined' || "" == deptId || isNaN(deptId) || parseInt(deptId) <= 0)) {
		$("#" + config.workerHiddenId).val('');
		hideDWResult('results_' + config.workerStr);
		return;
	}
	// 如果没有显示域则创建 主要解决是选择部门后还没创建员工的显示域
	if ($("#results_" + config.workerStr).length <= 0) {
		var rLeft = $("#" + config.workerStr).offset().left;// 设置层的left为指定组件的left距离
		// var
		// rTop=$("#"+config.workerStr).offset().top+$("#"+config.workerStr).height()+5;//设置层的top距离

		$("#" + config.workerStr)
				.after(
						'<div id="results_'
								+ config.workerStr
								+ '" style="border:1px solid #000000; overflow-x:hidden;width:230px;height:auto;background:#FCFCFC;position:absolute;left:'
								+ rLeft
								+ 'px;margin-top:0;*margin-top:22px;z-index:9999;font-size:12px;display:none;"></div>');
	}
	// ajax
	$
			.ajax({
				type : 'POST',
				dataType : 'json',
				url:_rootPath+'/v/deptworker/ajaxgetworker',
				data : {
					workerStr : $.trim(workerSearchStr),
					workerDeptId : deptId
				},
				success : function(msg) {
					var data = msg;
					var contentHTML = [];
					contentHTML
							.push('<ul style="font-family:\'宋体\',Arial;margin:0;padding:0;text-indent:0;width:100%;">');
					contentHTML
							.push('<li style="width:100%;background-color:#FFD700;text-indent:3px;line-height:2;color:#3c3c64;">');
					contentHTML
							.push('<span style="float:right;cursor:pointer;" onclick="hideDWResult(\'results_'
									+ config.workerStr
									+ '\');">[关闭]</span>员工列表</li>');
					var le = 0;
					if (data.infoNo == 1) {
						var jsonArr = eval(data.workerArr) || [];
						le = jsonArr.length;
						for ( var i = 0; i < le; i++) {
							if (i % 2 == 0) {
								contentHTML
										.push("<li style='width:100%;background-color:#FFF;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='setWorkerInfo(\""
												+ jsonArr[i].workerName
												+ "\",\""
												+ config.workerStr
												+ "\",\""
												+ jsonArr[i].id
												+ "\",\""
												+ jsonArr[i].workerId
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							} else {
								contentHTML
										.push("<li style='width:100%;background-color:#F0F1F7;color:#3c3c64;text-indent:3px;line-height:2;cursor:pointer;' onclick='setWorkerInfo(\""
												+ jsonArr[i].workerName
												+ "\",\""
												+ config.workerStr
												+ "\",\""
												+ jsonArr[i].id
												+ "\",\""
												+ jsonArr[i].workerId
												+ "\",\""
												+ config.workerHiddenId
												+ "\",\""
												+ jsonArr[i].deptName
												+ "\",\""
												+ config.deptStr
												+ "\",\""
												+ jsonArr[i].deptId
												+ "\",\""
												+ config.deptHiddenId
												+ "\",\""
												+ setWorkerFunName
												+ "\")'>");
							}
							contentHTML.push(jsonArr[i].deptName
									+ "&nbsp;&nbsp;<strong>"
									+ jsonArr[i].workerName + "</strong></li>");
						}
					} else {
						contentHTML
								.push('<li style="width:100%;background-color:#FFF;text-indent:3px;line-height:2;color:#3c3c64;text-align:center;"><无匹配数据></li>');

					}
					contentHTML.push('</ul>');
					contentHTML
							.push('<iframe frameborder="0" style="position:absolute;top:0px;left:0px; width:200px; height:2000px; z-index:-1; background:#DFFEBA;filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\'" scrolling="no"></iframe>');
					$("#results_" + config.workerStr)
							.html(contentHTML.join(''));
					contentHTML = "";
					if (le < 10) {
						$("#results_" + config.workerStr).css("height", "auto");
						$("#results_" + config.workerStr).css("overflow-y",
								"hidden");
					} else {
						$("#results_" + config.workerStr)
								.css("height", "266px");
						$("#results_" + config.workerStr).css("overflow-y",
								"auto");
					}
					// 显示结果域
					if (flg)
						showDWResult("results_" + config.workerStr);
				}
			});
}
